<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.29
     from lidoref.tnf on 19 December 2010 -->

<TITLE>LIDO - Reference Manual - Expressions</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#FF0000" BACKGROUND="gifs/bg.gif">
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0" VALIGN=BOTTOM>
<TR VALIGN=BOTTOM>
<TD WIDTH="160" VALIGN=BOTTOM>
<A HREF="http://eli-project.sourceforge.net/">
<IMG SRC="gifs/elilogo.gif" BORDER=0>
</A>&nbsp;
</TD>
<TD WIDTH="25" VALIGN=BOTTOM>
<img src="gifs/empty.gif" WIDTH=25 HEIGHT=25>
</TD>
<TD ALIGN=LEFT WIDTH="475" VALIGN=BOTTOM>
<A HREF="index.html"><IMG SRC="gifs/title.png" BORDER=0></A>
</TD>
<!-- |DELETE FOR SOURCEFORGE LOGO|
<TD>
<a href="http://sourceforge.net/projects/eli-project">
<img
  src="http://sflogo.sourceforge.net/sflogo.php?group_id=70447&amp;type=13"
  width="120" height="30"
  alt="Get Eli: Translator Construction Made Easy at SourceForge.net.
    Fast, secure and Free Open Source software downloads"/>
</a>
</TD>
|DELETE FOR SOURCEFORGE LOGO| -->
</TR>
</TABLE>

<HR size=1 noshade width=785 align=left>
<TABLE BORDER=0 CELLSPACING=2 CELLPADDING=0>
<TR>
<TD VALIGN=TOP WIDTH="160">
<h4>General Information</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="index.html">Eli: Translator Construction Made Easy</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gindex_1.html#SEC1">Global Index</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="faq_toc.html" >Frequently Asked Questions</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Tutorials</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="EliRefCard_toc.html">Quick Reference Card</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="novice_toc.html">Guide For new Eli Users</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="news_toc.html">Release Notes of Eli</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="nametutorial_toc.html">Tutorial on Name Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="typetutorial_toc.html">Tutorial on Type Analysis</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Reference Manuals</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ui_toc.html">User Interface</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="pp_toc.html">Eli products and parameters</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lidoref_toc.html">LIDO Reference Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ee.html" >Typical Eli Usage Errors</a> </td></tr>
</table>

<h4>Libraries</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lib_toc.html">Eli library routines</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="modlib_toc.html">Specification Module Library</a></td></tr>
</table>

<h4>Translation Tasks</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lex_toc.html">Lexical analysis specification</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="syntax_toc.html">Syntactic Analysis Manual</a></td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="comptrees_toc.html">Computation in Trees</a></td></tr>
</table>

<h4>Tools</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="lcl_toc.html">LIGA Control Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="show_toc.html">Debugging Information for LIDO</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="gorto_toc.html">Graphical ORder TOol</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="fw_toc.html">FunnelWeb User's Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="ptg_toc.html">Pattern-based Text Generator</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="deftbl_toc.html">Property Definition Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="oil_toc.html">Operator Identification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="tp_toc.html">Tree Grammar Specification Language</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="clp_toc.html">Command Line Processing</a> </td></tr>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="cola_toc.html">COLA Options Reference Manual</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="idem_toc.html">Generating Unparsing Code</a> </td></tr>
</table>
<p>
<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="mon_toc.html">Monitoring a Processor's Execution</a> </td></tr>
</table>

<h4>Administration</h4>

<table BORDER=0 CELLSPACING=0 CELLPADDING=0>
<tr valign=top><td><img src="gifs/gelbekugel.gif" WIDTH=7 HEIGHT=7 ALT=" o"> </td><td><a href="sysadmin_toc.html">System Administration Guide</a> </td></tr>
</table>

<HR WIDTH="100%">
<A HREF="mailto:eli-project-users@lists.sourceforge.net">
<IMG SRC="gifs/button_mail.gif" BORDER=0 ALIGN="left"></A>
<A HREF="index.html"><IMG SRC="gifs/home.gif" BORDER=0 ALIGN="right"></A>

</TD>
<TD VALIGN=TOP WIDTH="25"><img src="gifs/empty.gif" WIDTH=25 HEIGHT=25></TD>

<TD VALIGN=TOP WIDTH="600">
<H1>LIDO - Reference Manual</H1>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_6.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_8.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
<H1><A NAME="SEC9" HREF="lidoref_toc.html#SEC9">Expressions</A></H1>
<P>
An expression is evaluated as part of a computation. The evaluation may
yield a value, cause an effect, or both.
<A NAME="IDX120"></A>
<A NAME="IDX119"></A>
<P>
<H2><A NAME="SEC10" HREF="lidoref_toc.html#SEC10">Dependent Expressions</A></H2>
<P>
The evaluation of an expression depends on all attributes to which it refers.
The expression is evaluated only after all
those attributes are evaluated.
<A NAME="IDX121"></A>
<P>
Further attributes may be added as preconditions for expression evaluation
without using their values for computing the expression's result. The
additional attributes may describe a computational state that has to be reached
before the expression is evaluated. These attributes are specified by a 
<CODE>DependsClause</CODE>.
<A NAME="IDX122"></A>
<P>
<H4>Syntax</H4>
<PRE>
    Expression    ::= SimpExpr [ DependsClause ]
    DependsClause ::= '&#60;-' DepAttrList
    DepAttrList   ::= DepAttr
                    | '(' DepAttrs ')'
    DepAttrs      ::= DepAttrs ',' DepAttrs
                    | DepAttr
    DepAttr       ::= Attribute | RemoteAccess | RhsAttrs
<A NAME="IDX123"></A>
<A NAME="IDX124"></A>
<A NAME="IDX125"></A>
<A NAME="IDX126"></A>
<A NAME="IDX127"></A>
</PRE>
<P>
<H4>Examples</H4>
<PRE>
    GetProp (UseId.Key,0) &#60;- UseId.PropIsSet
    printf ("%s ", Opr.String) &#60;- (Expr[2].printed, Expr.[3].printed)
</PRE>
<P>
A <CODE>DependsClause</CODE> has a <CODE>VOID</CODE> context, i.e. its attributes
may have any type; their values are discarded.
<A NAME="IDX128"></A>
<P>
<H2><A NAME="SEC11" HREF="lidoref_toc.html#SEC11">Terminal Access</A></H2>
<A NAME="IDX129"></A>
<P>
Named terminal symbols that occur in a production represent values
that are usually obtained from corresponding input tokens when the
tree node is constructed. Those values can be used in both rule 
and symbol computations.
<A NAME="IDX130"></A>
<P>
<H4>Syntax</H4>
<PRE>
    SimpExpr ::= SymbolRef
               | 'TERM' [ '[' Number ']' ]
<A NAME="IDX131"></A>
<A NAME="IDX132"></A>
<A NAME="IDX133"></A>
</PRE>
<P>
<H4>Examples</H4>
<PRE>
    RULE:   DefIdent ::= Ident COMPUTE
      DefIdent.Key = DefineIdn (DefIdent.Env, Ident);
    END;
    RULE:   Point ::= '(' Numb Numb ')' COMPUTE
      printf ("X = %d, Y = %d\n", Numb[1], Numb[2]);
    END;
    SYMBOL Point COMPUTE
      printf ("X = %d, Y = %d\n", TERM[1], TERM[2]);
    END;
</PRE>
<P>
In rule computations the value of a terminal in the production
is denoted by the <CODE>SymbName</CODE>, which is indexed if and only if there
are multiple occurrences of the <CODE>SymbName</CODE> in the production.
<P>
Note: In a rule computation a non-indexed identifier that is not a name
of a symbol in the production of this rule denotes some entity of
the generated C program, even if it coincides with the name of a
terminal that occurs in other productions.
<P>
In lower computations of a symbol <CODE>X</CODE> terminal values are accessed by
<CODE>TERM</CODE> or <CODE>TERM[i]</CODE>, where <CODE>TERM</CODE> is equivalent to
<CODE>TERM[1]</CODE>. <CODE>TERM[i]</CODE> denotes the <CODE>i</CODE>-th terminal in each
production that has <CODE>X</CODE> (or a symbol that inherits <CODE>X</CODE>) on its
left-hand side, regardless of the terminal's name.
<A NAME="IDX134"></A>
<P>
<H4>Restrictions</H4>
<P>
<CODE>TERM</CODE> must not be used in rule computations or in upper symbol
computations.
<P>
A terminal accessed in a symbol computation must exist in every production
the computation is associated with.
<P>
<H2><A NAME="SEC12" HREF="lidoref_toc.html#SEC12">Simple Expressions</A></H2>
<A NAME="IDX135"></A>
<P>
Expressions are written as nested function calls where the basic operands are
attributes, C identifiers and C literals. 
The functions are either predefined in LIDO or
their definitions are supplied by the user in the form of C functions or
macros outside the LIDO specification. There is no operator notation for
expressions in LIDO.
<A NAME="IDX137"></A>
<A NAME="IDX138"></A>
<A NAME="IDX136"></A>
<P>
<H4>Syntax</H4>
<PRE>
    SimpExpr  ::= C_Name | C_Integer | C_Float | C_Char | C_String
                |  Attribute | RemoteAccess | RhsAttrs
                |  FunctionName '(' [ Arguments ] ')'
    Arguments ::= Arguments ',' Arguments
                |  Expression
<A NAME="IDX139"></A>
<A NAME="IDX140"></A>
<A NAME="IDX141"></A>
<A NAME="IDX142"></A>
<A NAME="IDX143"></A>
<A NAME="IDX144"></A>
<A NAME="IDX145"></A>
<A NAME="IDX146"></A>
</PRE>
<P>
<H4>Examples</H4>
<PRE>
    printf ("Val = %d\n", Expr.val)
    IF (LT (Expr.val, 0), 0, Expr.val)
</PRE>
<P>
Evaluation of a function call notation in LIDO has the same effect and
result as the equivalent notation in C.
<P>
There are some predefined <CODE>FunctionNames</CODE> that have a special
meaning in LIDO (see  <A HREF="lidoref_12.html#SEC21">Predefined Entities</A>).
<P>
Function calls need not yield a value if they are in a <CODE>VOID</CODE> context.
All arguments of a function call are in a value context.
<A NAME="IDX148"></A>
<A NAME="IDX147"></A>
<P>
<CODE>C_Name</CODE>, <CODE>C_Integer</CODE>, <CODE>C_Float</CODE>, <CODE>C_Char</CODE>, 
<CODE>C_String</CODE> are names and literals denoted as in C.
<P>
<H4>Restrictions</H4>
<P>
Every <CODE>FunctionName</CODE> and <CODE>C_Name</CODE> must be predefined in LIDO or
supplied by a user definition.
<P>
All arguments of non-predefined functions must yield a (non-<CODE>VOID</CODE>)
value. For predefined LIDO functions specific rules apply
(see  <A HREF="lidoref_12.html#SEC21">Predefined Entities</A>).
<P>
Type consistency for non-<CODE>VOID</CODE> types is not checked by LIGA.
Those checks are deferred to the compilation of the generated evaluator.
<P>
A <CODE>C_Name</CODE> or a <CODE>FunctionName</CODE> should not begin with an underscore,
in order to avoid conflicts with LIGA generated identifiers.
<P>
<HR size=1 noshade width=600 align=left>
<P>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_6.html"><IMG SRC="gifs/prev.gif" ALT="Previous Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_8.html"><IMG SRC="gifs/next.gif" ALT="Next Chapter" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT=""><A HREF="lidoref_toc.html"><IMG SRC="gifs/up.gif" ALT="Table of Contents" BORDER="0"></A>
<IMG SRC="gifs/empty.gif" WIDTH=25 HEIGHT=25 ALT="">
<HR size=1 noshade width=600 align=left>
</TD>
</TR>
</TABLE>

</BODY></HTML>
